home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / daemons / migd / RCS / migd.h,v < prev    next >
Encoding:
Text File  |  1992-05-10  |  12.3 KB  |  489 lines

  1. head     2.2;
  2. branch   ;
  3. access   ;
  4. symbols  before_fairness_changes:2.0 ckpt1:1.3;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 2.2
  10. date     90.09.24.14.45.38;  author douglis;  state Exp;
  11. branches ;
  12. next     2.1;
  13.  
  14. 2.1
  15. date     90.07.05.13.20.41;  author douglis;  state Exp;
  16. branches ;
  17. next     2.0;
  18.  
  19. 2.0
  20. date     90.06.30.17.10.43;  author douglis;  state Stable;
  21. branches ;
  22. next     1.7;
  23.  
  24. 1.7
  25. date     90.05.28.17.08.37;  author douglis;  state Exp;
  26. branches ;
  27. next     1.6;
  28.  
  29. 1.6
  30. date     90.05.02.14.36.11;  author douglis;  state Exp;
  31. branches ;
  32. next     1.5;
  33.  
  34. 1.5
  35. date     90.04.27.00.59.23;  author douglis;  state Exp;
  36. branches ;
  37. next     1.4;
  38.  
  39. 1.4
  40. date     90.04.24.18.00.47;  author douglis;  state Exp;
  41. branches ;
  42. next     1.3;
  43.  
  44. 1.3
  45. date     90.03.12.13.45.52;  author douglis;  state Exp;
  46. branches ;
  47. next     1.2;
  48.  
  49. 1.2
  50. date     90.02.28.10.54.04;  author douglis;  state Exp;
  51. branches ;
  52. next     1.1;
  53.  
  54. 1.1
  55. date     90.02.15.19.19.33;  author douglis;  state Exp;
  56. branches ;
  57. next     ;
  58.  
  59.  
  60. desc
  61. @Declarations of constants and structures used by the migration
  62. daemon.
  63. @
  64.  
  65.  
  66. 2.2
  67. log
  68. @added migd_NeverRunGlobal flag
  69. @
  70. text
  71. @/*
  72.  * migd.h --
  73.  *
  74.  *    Declarations of constants and structures used by the migration
  75.  *    daemon.
  76.  *
  77.  * Copyright 1989 Regents of the University of California
  78.  * Permission to use, copy, modify, and distribute this
  79.  * software and its documentation for any purpose and without
  80.  * fee is hereby granted, provided that the above copyright
  81.  * notice appear in all copies.  The University of California
  82.  * makes no representations about the suitability of this
  83.  * software for any purpose.  It is provided "as is" without
  84.  * express or implied warranty.
  85.  *
  86.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 2.1 90/07/05 13:20:41 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  87.  */
  88.  
  89. #ifndef _MIGD
  90. #define _MIGD
  91.  
  92. #include <sprite.h>
  93. #include <fs.h>
  94. #include <mig.h>
  95. #include <list.h>
  96. #include <pdev.h>
  97.  
  98.  
  99. /*
  100.  * Types of pdev connections:
  101.  *
  102.  *    MIGD_DAEMON    - a daemon is talking to us.
  103.  *    MIGD_USER    - a user process is talking to us.
  104.  *    MIGD_LOCAL    - a local process is talking to us (to get the load
  105.  *              average or perform an eviction).
  106.  *    MIGD_NEW    - the connection is new and we don't know who is at the
  107.  *              other end.
  108.  *    MIGD_CLOSED    - the connection has been forcibly closed and there's
  109.  *              nothing more we need to do with it.
  110.  */
  111. typedef enum {
  112.     MIGD_DAEMON,
  113.     MIGD_USER,
  114.     MIGD_LOCAL,
  115.     MIGD_NEW,
  116.     MIGD_CLOSED,
  117. } Migd_ServiceType;
  118.  
  119. /*
  120.  * Define a structure to keep track of open connections.
  121.  * This is reachable from the ClientData part of a Pdev_Stream.
  122.  */
  123. typedef struct {
  124.     List_Links nextStream;    /* Next stream we have open. */
  125.     Pdev_Stream *streamPtr;    /* Back pointer to pdev info. */
  126.     Migd_ServiceType type;    /* Type of connection. */
  127.     int user;            /* User invoked by. */
  128.     int host;            /* Host invoked by. */
  129.     int processID;        /* Process ID of invoker. */
  130.     int openID;                /* Unique identifier. */
  131.     int    defaultSelBits;        /* What to set default to after an
  132.                    operation. */
  133.     int format;            /* Byte order of this host (set on first
  134.                    ioctl, used by read/write). */
  135.     int    numRequested;        /* Total number of hosts requested. */
  136.     int numObtained;        /* Total number of hosts obtained. */
  137.     int numEvicted;        /* Total number of hosts given and then
  138.                    reclaimed due to eviction. */
  139.     int numInUse;        /* Number of hosts currently assigned to this
  140.                    process, which is the length of the
  141.                    currentRequests list. */
  142.     int    maxRequests;        /* Maximum number of hosts requested.
  143.                    This may be less than numRequested if
  144.                    hosts are assigned, then returned (or
  145.                    reclaimed), then assigned again. */
  146.     int    maxObtained;        /* Maximum number of hosts obtained.
  147.                    This may be less than numAssigned if
  148.                    hosts are assigned, then returned (or
  149.                    reclaimed), then assigned again. */
  150.     int denied;            /* Non-zero if ever denied a host request. */
  151.     int    numStolen;        /* Number of times we stole hosts back. */
  152.     int    stoleTime;        /* Time at which we stole hosts back. */
  153.     List_Links currentRequests;    /* List of outstanding requests. */
  154.     List_Links messages;    /* Messages to pass to process, defined in
  155.                    global.c. */
  156.     struct Migd_WaitList *waitPtr; /* Waiting list, if any. */
  157. } Migd_OpenStreamInfo;
  158.  
  159. /* 
  160.  * Define a structure for keeping track of clients that want more
  161.  * hosts than we can give them.
  162.  */
  163. typedef struct Migd_WaitList {
  164.     List_Links links;        /* Link to next client. */
  165.     Migd_OpenStreamInfo *cltPtr;/* Client. */
  166. } Migd_WaitList;
  167.  
  168. /*
  169.  * Define a structure for managing host information.  This is
  170.  * a superset of the Mig_Info that clients can see.
  171.  */
  172. typedef struct Migd_Info {
  173.     List_Links    links;        /* Links within list of idle hosts. */
  174.     Mig_Info    info;        /* Standard info. */
  175.     int        archType;    /* Numeric identifier for architecture type. */
  176.     int     flags;        /* Additional info, defined below. */
  177.     List_Links  clientList;    /* Clients using this host
  178.                    (Migd_RequestInfo structures). */
  179.     Migd_OpenStreamInfo *cltPtr; /* Pointer back to open stream info
  180.                        for daemon. */
  181.     char     *name;        /* Name of host, for debugging purposes. */
  182.     int        lastHostAssigned; /* Host running process to which this host
  183.                      was last assigned. Used for
  184.                      statistical purposes. */
  185. } Migd_Info;
  186.  
  187. /*
  188.  * Flags for Migd_Info:
  189.  *    MIGD_CHECK_COUNT    - Check when the count of foreign
  190.  *                  processes decreases to determine when
  191.  *                  host is idle again.
  192.  *    MIGD_WAS_EMPTY        - Host had no foreign processes the
  193.  *                  last time we checkpointed.
  194.  */
  195. #define MIGD_CHECK_COUNT 1    
  196. #define MIGD_WAS_EMPTY   2    
  197.  
  198. /*
  199.  * Subscripts into the queueThreshold array.
  200.  */
  201. #define MIGD_MIN_THRESHOLD 0
  202. #define MIGD_MAX_THRESHOLD 1
  203.  
  204. /*
  205.  * Arbitrary value larger than the load average on any node (we hope!)
  206.  */
  207. #define MIGD_MAX_LOAD 1000.0
  208.  
  209. /*
  210.  * If we have to deal with severe clock skew, define USE_GLOBAL_CLOCK.
  211.  */
  212. #define USE_GLOBAL_CLOCK
  213.  
  214.  
  215. #define mnew(type)    (type *)Malloc(sizeof(type))
  216.  
  217. /*
  218.  * We always want to print our processID because we want to catch multiple
  219.  * daemons using the same log file.
  220.  */
  221. #define PRINT_PID fprintf(stderr, "%x: ", migd_Pid)
  222.  
  223. /*
  224.  * We probably always want to log certain messages to syslog, but we
  225.  * also want them to go to a log file -- at least while syslog isn't
  226.  * logged permanently!
  227.  */
  228. #define SYSLOG0(level, message) \
  229.     syslog(level, message); \
  230.     if (migd_LogToFiles) { \
  231.     PRINT_PID; \
  232.     fprintf(stderr, message); \
  233.     }
  234. #define SYSLOG1(level, message, arg1) \
  235.     syslog(level, message, arg1); \
  236.     if (migd_LogToFiles) { \
  237.     PRINT_PID; \
  238.     fprintf(stderr, message, arg1); \
  239.     }
  240. #define SYSLOG2(level, message, arg1, arg2) \
  241.     syslog(level, message, arg1, arg2); \
  242.     if (migd_LogToFiles) { \
  243.     PRINT_PID; \
  244.     fprintf(stderr, message, arg1, arg2); \
  245.     }
  246. #define SYSLOG3(level, message, arg1, arg2, arg3) \
  247.     syslog(level, message, arg1, arg2, arg3); \
  248.     if (migd_LogToFiles) { \
  249.     PRINT_PID; \
  250.     fprintf(stderr, message, arg1, arg2, arg3); \
  251.     }
  252. #define DATE() \
  253.     if (migd_LogToFiles) { \
  254.         int t; \
  255.     t = time(0); \
  256.     fprintf(stderr, "%x %s", migd_Pid, ctime(&t)); \
  257.     }
  258.  
  259. /*
  260.  * Macro to add to a counter, watching for overflow.  We use unsigned
  261.  * integers and wrap around if the high-order bit gets set.  This assumes
  262.  * that the amount to be added each time is
  263.  * relatively small (so we can't miss the overflow bit).
  264.  */
  265.  
  266. #define OVERFLOW_BIT (1 << (sizeof(unsigned int) * 8 - 1))
  267. #define ADD_WITH_OVERFLOW(counter, thisCount) \
  268.     counter[MIG_COUNTER_LOW] += thisCount; \
  269.     if (counter[MIG_COUNTER_LOW] & OVERFLOW_BIT) { \
  270.         counter[MIG_COUNTER_HIGH] += 1; \
  271.         counter[MIG_COUNTER_LOW] &= ~OVERFLOW_BIT; \
  272.     }
  273.  
  274.  
  275.  
  276.  
  277.  
  278. extern char     *Malloc();        /* Utility. */
  279.  
  280. extern int    migd_Debug;
  281. extern int    migd_Quit;
  282. extern int    migd_Verbose;
  283. extern int    migd_DontFork;
  284. extern int    migd_Version;
  285. extern int    migd_DoStats;
  286. extern int    migd_NeverEvict;
  287. extern int    migd_NeverRunGlobal;
  288. extern int    migd_LogToFiles;
  289. extern int    migd_AlwaysAccept;
  290. extern int    migd_GlobalMaster;
  291. extern int    migd_Pid;
  292. extern char    *migd_GlobalPdevName;
  293. extern char    *migd_GlobalErrorName;    /* Place to write errors for global
  294.                        daemon, or NULL. */
  295. extern char    *migd_LocalPdevName;
  296. extern char    *migd_ProgName;
  297. extern int    migd_HostID;
  298. extern char    *migd_HostName;
  299. extern int    migd_AlwaysAccept;
  300. extern int    migd_NeverAccept;
  301. extern int    migd_MigVersion;
  302. extern int    migd_WriteInterval;
  303. extern int    migd_LoadInterval;
  304. extern double    migd_Weights[];
  305. extern Mig_SystemParms migd_Parms;
  306. extern Fs_TimeoutHandler migd_TimeoutToken;
  307.  
  308. extern void    Migd_GatherLoad();
  309. extern void    Migd_GetLocalLoad();
  310. extern void    Migd_End();
  311. extern int    Migd_CreateGlobal();
  312. extern int    Migd_ContactGlobal();
  313. extern void     Migd_HandleRequests();
  314. extern void     Migd_Evict();
  315. extern int    Migd_GetParms();
  316. extern int    Migd_SetParms();
  317. extern int    Migd_EvictIoctl();
  318.  
  319. #endif _MIGD
  320.  
  321.  
  322.  
  323. @
  324.  
  325.  
  326. 2.1
  327. log
  328. @added info for stolen stuff
  329. @
  330. text
  331. @d16 1
  332. a16 1
  333.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 2.0 90/06/30 17:10:43 douglis Stable Locker: douglis $ SPRITE (Berkeley)
  334. d217 1
  335. @
  336.  
  337.  
  338. 2.0
  339. log
  340. @Changing version numbers.
  341. @
  342. text
  343. @d16 1
  344. a16 1
  345.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.7 90/05/28 17:08:37 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  346. d81 2
  347. @
  348.  
  349.  
  350. 1.7
  351. log
  352. @minor change to documentation
  353. @
  354. text
  355. @d16 1
  356. a16 1
  357.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.6 90/05/02 14:36:11 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  358. @
  359.  
  360.  
  361. 1.6
  362. log
  363. @added 'denied' field to client struct, for statistics purposes.
  364. @
  365. text
  366. @d16 1
  367. a16 1
  368.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.5 90/04/27 00:59:23 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  369. d110 3
  370. a112 2
  371.     int        lastHostAssigned; /* Last host assigned to a process on this
  372.                      host.  Used for statistical purposes. */
  373. @
  374.  
  375.  
  376. 1.5
  377. log
  378. @changes for statistics gathering.
  379. @
  380. text
  381. @d16 1
  382. a16 1
  383.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.4 90/04/24 18:00:47 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  384. d80 1
  385. @
  386.  
  387.  
  388. 1.4
  389. log
  390. @intermediate checkpoint
  391. @
  392. text
  393. @d16 1
  394. a16 1
  395.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.3 90/03/12 13:45:52 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  396. d66 3
  397. a68 1
  398.     int numAssigned;        /* Total number of hosts assigned. */
  399. d72 1
  400. a72 1
  401.     int    maxRequested;        /* Maximum number of hosts requested.
  402. d76 4
  403. d109 2
  404. d184 18
  405. @
  406.  
  407.  
  408. 1.3
  409. log
  410. @print pid's before messages in global log file; print dates here and
  411. there; open files in append mode; changed file names to be in admin
  412. subdir.  [this is a recording. beep!]
  413. @
  414. text
  415. @d16 1
  416. a16 1
  417.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.2 90/02/28 10:54:04 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  418. d63 1
  419. a63 1
  420.     int format;        /* Byte order of this host (set on first
  421. d65 9
  422. a73 3
  423.     int numHostsUsed;        /* Number of hosts assigned to this process,
  424.                    which is the length of the currentRequests
  425.                    list. */
  426. a80 28
  427.  * A structure is used to keep track of outstanding requests,
  428.  * i.e., idle hosts that have been assigned to a process and not yet
  429.  * returned.   It points back to the open stream info and to two linked
  430.  * lists, one that's per stream and one that's per host.
  431.  */
  432. typedef struct Migd_RequestInfo {
  433.     List_Links  nextClientRequest;    /* Link to next request by same
  434.                        client. */
  435.     List_Links  nextHostRequest;    /* Link to next request for this
  436.                        host. */
  437.     int priority;            /* Priority of processes. */
  438.     int numProcessors;            /* Number of processors assigned. */
  439.     int idleTime;            /* Idle time of host at time of
  440.                        request (in case of eviction,
  441.                        for statistics). */
  442.     int flags;                /* Flags applied to request. */
  443.     union {
  444.     Migd_OpenStreamInfo *cltPtr;     /* Pointer back to open stream info
  445.                        for client. */
  446.     int processID;            /* ID of process, if agent. */
  447.     } client;
  448.     struct Migd_Info *migdPtr;        /* Pointer back to host assigned. */
  449. } Migd_RequestInfo;
  450.  
  451. #define NEXT_HOST_REQUEST_TO_INFO(listPtr) \
  452.     ( (Migd_RequestInfo *)((int)(listPtr) - sizeof(List_Links)) )
  453.  
  454. /* 
  455. d184 3
  456. @
  457.  
  458.  
  459. 1.2
  460. log
  461. @added macros to print msgs to both syslog & error log when appropriate.  
  462. added config defines, like USE_GLOBAL_CLOCK.
  463. @
  464. text
  465. @d16 1
  466. a16 1
  467.  * $Header: /sprite/src/daemons/migd/RCS/migd.h,v 1.1 90/02/15 19:19:33 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  468. d158 6
  469. d171 1
  470. d177 1
  471. d183 1
  472. d189 1
  473. d192 6
  474. d209 1
  475. @
  476.  
  477.  
  478. 1.1
  479. log
  480. @Initial revision
  481. @
  482. text
  483. @d16 1
  484. a16 1
  485.  * $Header: /user2/douglis/pdev_mig/migd/RCS/migd.h,v 2.4 90/02/14 11:46:43 douglis Exp Locker: douglis $ SPRITE (Berkeley)
  486. d149 4
  487. d156 27
  488. @
  489.